#ifndef _WEBSOCKET_HANDLER_H
#define _WEBSOCKET_HANDLER_H

#include <string>
#include <iostream>
#include <jsoncpp/json/json.h>
#include <wsim/websocket_common.h>
#include <pthread.h>

using namespace std;
static pthread_mutex_t mutex_client_map_lock;
/**************************
 * websocket处理数据类
 * ***********************/
class websocket_handler{
	private:
		int fd;//客户句柄
		std::string nickname;//客户名称
		std::string uuid;//客户UUID
        std::string mood;//心情
        bool bReg;//是否注册
		std::string organ;//机构
		std::string group;//兴趣组
	public:
        websocket_handler(websocket_handler* src);
		websocket_handler(int f);
		~websocket_handler();
		void reNickname(string nick);
		int cmpNickname(string nick);
        int cmpUUID(string id);
        int cmpFd(int f);
		string  getNickname();
		string	getUUID();
        void reMood(string s);
         string getMood();
         int getFd();
        bool getReg();
        void reged();
		string getGroup();
		void reGroup(string val);
		string getOrgan();
		void reOrgan(string val);
};

void addClient(int fd);
void deleteClient(int fd);
void setClientNickname(int fd ,string nickname,bool b);
void setClientMood(int fd ,string mood);
void setClientOrgan(int fd ,string val);
void setClientGroup(int fd ,string val);
websocket_handler* getClientValue(int fd);
bool isClient(int fd);
int isNickname(string nickname);
void toNotInClients(int fd,char* data,int size,WebsocketData_Type type);
Json::Value clientMapToArray();
Json::Value clientMapNoRegToArray();
Json::Value clientMapRegToArray();
Json::Value clientMapOrganToArray(string organ);
Json::Value clientMapGroupToArray(string group);
#endif